//
//  addScrollerView.m
//  Estate
//
//  Created by heyong on 16/6/3.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "addScrollerView.h"

@implementation addScrollerView
- (UIScrollView *)scrollView{
    if(_scrollView==nil){
        _scrollView=[[UIScrollView alloc]initWithFrame:CGRECTS(0, 0, 376, 667)];
    }
    return _scrollView;
}
/**项目名*/
- (UILabel *)pName{
    if(_pName==nil){
        _pName=[[UILabel alloc]init];
    }
    return _pName;
}
/**位置*/
- (UILabel *)weiZhi{
    if(_weiZhi==nil){
        _weiZhi=[[UILabel alloc]init];
    }
    return _weiZhi;
}
/**位置btn*/
-(UIButton *)wzBtn{
    if(!_wzBtn){
        _wzBtn=[[UIButton alloc]init];
    }
    return _wzBtn;
}
/**巡视*/
-(UIButton *)xsBtn{
    if(!_xsBtn){
        _xsBtn=[[UIButton alloc]init];
    }
    return _xsBtn;
}
/**安全*/
-(UIButton *)aqBtn{
    if(!_aqBtn){
        _aqBtn=[[UIButton alloc]init];
    }
    return _aqBtn;
}
/**其他*/
-(UIButton *)qtBtn{
    if(!_qtBtn){
        _qtBtn=[[UIButton alloc]init];
    }
    return _qtBtn;
}
/**记录人*/
- (UILabel *)jlName{
    if(_jlName==nil){
        _jlName=[[UILabel alloc]init];
    }
    return _jlName;
}
 /**时间*/
- (UILabel *)time{
    if(_time==nil){
        _time=[[UILabel alloc]init];
    }
    return _time;
}
/**标题*/
- (UITextField *)title{
    if(_title==nil){
        _title=[[UITextField alloc]init];
    }
    return _title;
}
/**内容*/
- (UITextView *)content{
    if(_content==nil){
        _content=[[UITextView alloc]init];
    }
    return _content;
}
- (UIButton *)addFileBtn{
    if(_addFileBtn==nil){
        _addFileBtn=[[UIButton alloc]init];
    }
    return _addFileBtn;
}

-(UIImageView *)FileImage{
    if(_FileImage==nil){
        _FileImage=[[UIImageView alloc]init];
     
    }
    return _FileImage;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    [self addSubview:self.scrollView];
    //设置scrollView属性
    self.scrollView.contentSize=CGSizeMake(0, DEF_SCREEN_HEIGHT);
    self.scrollView.backgroundColor=[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00];;
    //添加上部视图
    [self createTopView];
}

//添加上部视图
- (void)createTopView{
    self.top=[[UILabel alloc]initWithFrame:CGRECTS(0, 0, 375, 40)];
    _top.textColor=[UIColor colorWithRed:0.20 green:0.60 blue:0.56 alpha:1.00];
    _top.text=@"2016 - 06 - 03现场记录编辑录入";
    _top.textAlignment=1;
    _top.font=[UIFont systemFontOfSize:14];
    _top.backgroundColor=[UIColor colorWithRed:0.85 green:0.93 blue:0.98 alpha:1.00];
    [self.scrollView addSubview:_top];
    
    view1=[[UIView alloc]initWithFrame:CGRECTS(0, 40, 375, 204)];
    view1.backgroundColor=[UIColor whiteColor];
    [self createView1Lable];
    
    UIImageView *view1BottonImg=[[UIImageView alloc]initWithFrame:CGRECTS(0, 243, 375, 15)];
    view1BottonImg.image=[UIImage imageNamed:@"juchishang"];
    
    UIImageView *view2topImg=[[UIImageView alloc]initWithFrame:CGRECTS(0, 260, 375, 15)];
    view2topImg.image=[UIImage imageNamed:@"juchixia"];
    
    //创建view2
    view2=[[UIView alloc]initWithFrame:CGRECTS(0, 275, 375, 180)];
    view2.backgroundColor=[UIColor whiteColor];
    [self createView2Lable];
    
    UIImageView *view2BottonImg=[[UIImageView alloc]initWithFrame:CGRECTS(0, 455, 375, 15)];
    view2BottonImg.image=[UIImage imageNamed:@"juchishang"];

    //创建附件信息
    UILabel *labfu=[[UILabel alloc]initWithFrame:CGRECTS(10, 465, 200, 40)];
    labfu.text=@"附件信息";
    labfu.textColor=[UIColor colorWithRed:0.10 green:0.56 blue:0.49 alpha:1.00];
    labfu.font=[UIFont systemFontOfSize:15.];
    [self.scrollView addSubview:labfu];
    
    //添加附件按钮
    [self cteateAddFujian];
    
    [self.scrollView addSubview:view1];
    [self.scrollView addSubview:view1BottonImg];
    [self.scrollView addSubview:view2];
    [self.scrollView addSubview:view2topImg];
    [self.scrollView addSubview:view2BottonImg];
}
- (void)createView1Lable{
    NSArray *arr=@[@"记     录 ：",@"位     置 ：",@"类     型 ：",@"记 录 人：",@"时     间 ："];
    for(int i=0;i<5;i++){
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRECTS(10, i*40, 80, 40)];
        [view1 addSubview:lab];
        lab.text=arr[i];
        lab.font=[UIFont systemFontOfSize:14.];
        lab.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
        //添加分割线
        UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(lab.frame), DEF_SCREEN_WIDTH-20, 1)];
        line.backgroundColor=[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1.00];
        [view1 addSubview:line];
    }
    
    [view1 addSubview:self.pName];
    self.pName.font=[UIFont systemFontOfSize:14.];
    self.pName.text=@"北京市丰台区****建筑项目公司";
    self.pName.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
    self.pName.frame=CGRECTS(85, 0, 295, 40);
    
    [view1 addSubview:self.weiZhi];
    self.weiZhi.font=[UIFont systemFontOfSize:14.];
    self.weiZhi.text=@"北区三号楼A座";
    self.weiZhi.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
    self.weiZhi.frame=CGRECTS(85, 40, 150, 40);
    
    [view1 addSubview:self.wzBtn];
    [self.wzBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.weiZhi.mas_centerY);
        make.left.mas_equalTo(self.weiZhi.mas_right).offset(5);
        make.width.offset(16);
        make.height.offset(22);
    }];
    [self.wzBtn setImage:[UIImage imageNamed:@"dingwei"] forState:UIControlStateNormal];
    
    //巡视
    [view1 addSubview:self.xsBtn];
    _xsBtn.frame=CGRECTS(85, 80, 60, 40);
    _xsBtn.tag=100;
    [_xsBtn setTitle:@"巡视" forState:UIControlStateNormal];
    [_xsBtn setTitleColor:[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00] forState:UIControlStateNormal];
    _xsBtn.titleLabel.font=[UIFont systemFontOfSize:14.];
    [_xsBtn setImage:[UIImage imageNamed:@"weixuanzhong" ]forState:UIControlStateNormal];
    [_xsBtn setImage:[UIImage imageNamed:@"xuanzhong" ] forState:UIControlStateSelected];

    //安全
    [view1 addSubview:self.aqBtn];
    _aqBtn.frame=CGRECTS(140, 80, 60, 40);
     _aqBtn.tag=101;
    [_aqBtn setTitle:@"安全" forState:UIControlStateNormal];
    [_aqBtn setTitleColor:[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00] forState:UIControlStateNormal];
    _aqBtn.titleLabel.font=[UIFont systemFontOfSize:14.];
    [_aqBtn setImage:[UIImage imageNamed:@"weixuanzhong" ]forState:UIControlStateNormal];
    [_aqBtn setImage:[UIImage imageNamed:@"xuanzhong" ] forState:UIControlStateSelected];
    
    //其他
    [view1 addSubview:self.qtBtn];
    _qtBtn.frame=CGRECTS(190, 80, 60, 40);
     _qtBtn.tag=102;
    [_qtBtn setTitle:@"其他" forState:UIControlStateNormal];
    [_qtBtn setTitleColor:[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00] forState:UIControlStateNormal];
    _qtBtn.titleLabel.font=[UIFont systemFontOfSize:14.];
    [_qtBtn setImage:[UIImage imageNamed:@"weixuanzhong" ]forState:UIControlStateNormal];
    [_qtBtn setImage:[UIImage imageNamed:@"xuanzhong" ] forState:UIControlStateSelected];
    
    [view1 addSubview:self.jlName];
    self.jlName.font=[UIFont systemFontOfSize:14.];
    self.jlName.text=@"监理甲";
    self.jlName.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
    self.jlName.frame=CGRECTS(85, 120, 150, 40);
    
    [view1 addSubview:self.time];
    self.time.font=[UIFont systemFontOfSize:14.];
    self.time.text=@"2016-06-03 11:26:14";
    self.time.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
    self.time.frame=CGRECTS(85, 160, 295, 40);
    
}

- (void)createView2Lable{
    NSArray *arr=@[@"标    题  ：",@"内    容  ："];
    for(int i=0;i<2;i++){
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRECTS(10, i*40, 80, 40)];
        [view2 addSubview:lab];
        lab.text=arr[i];
        lab.font=[UIFont systemFontOfSize:14.];
        lab.textColor=[UIColor colorWithRed:0.50 green:0.50 blue:0.50 alpha:1.00];
        //添加分割线
        if(i==0){
            UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(lab.frame), DEF_SCREEN_WIDTH-20, 1)];
            line.backgroundColor=[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1.00];
              [view2 addSubview:line];
        }
    }
    
    [view2 addSubview:self.title];
    self.title.frame=CGRECTS(85, 0, 300, 40);
    self.title.delegate=self;
    
    [view2 addSubview:self.content];
    self.content.layer.borderColor=[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1.00].CGColor;
    self.content.layer.borderWidth=1;
    self.content.layer.cornerRadius=5.;
    self.content.delegate=self;
    self.content.frame=CGRECTS(10, 80, 355, 90);
}

-(void)cteateAddFujian{
    [self.scrollView addSubview:self.addFileBtn];
    self.addFileBtn.frame=CGRECTS(10, 505, 172.5, 120);
    self.addFileBtn.layer.cornerRadius=5.;
    self.addFileBtn.backgroundColor=[UIColor colorWithRed:0.86 green:0.86 blue:0.86 alpha:1.00];
    [self.addFileBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
}

#pragma mark--Delagate

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_title resignFirstResponder];
    return  YES;
}

@end
